<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>查询个人信息</title>
    <link rel="stylesheet" href="./layui/css/layui.css" media="all">
</head>
<body>

<table id="userList" lay-filter="userTable"></table>

<script type="text/html" id="userListBar">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
</script>



<script src="./layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->


<script type="text/javascript" charset="utf-8">
    layui.use([ "table", "jquery" ], function() {
        var table = layui.table,
            $ = layui.$;

        var tableIns = table.render({
            elem : '#userList',
            cols : [ [ {
                type : 'checkbox'
            }, {
                field : "userNo",
                title : "人员编号",
                align : "center",
                sort: true
            }, {
                field : "username",
                title : "姓名",
                align : "center"
            }, {
                field : "identity",
                title : "身份",
                templet:function(d){
                    if(d.identity=='0'){
                        return "学生";
                    }else if(d.identity=='1'){
                        return "教师";
                    }else{
                        return d.identity;
                    }
                },
                align : "center",
            }, {
                field : "departmentName",
                title : "院系名",
                align : "center",
                sort: true
            }, {
                field : "clazzNo",
                title : "班级编号",
                align : "center",
                sort: true
            },

                {
                    title : "操作",
                    width : 170,
                    fixed : "right",
                    align : "center",
                    toolbar : "#userListBar"
                } ] ],
            url : '/evaluation/user/personal',
            cellMinWidth : 80, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            page : true,
            limits : [ 3, 5, 10 ],
        });


        //添加或者修改新用户
        function addNews(location) {
            var index = layui.layer.open({
                title: "用户",
                type: 2,
                anim:4,
                maxmin:true,
                content: location,
                end: function () {
                    tableIns.reload({
                        page : {
                            curr : 1
                            //重新从第 1 页开始
                        },

                    });
                    // layer.alert("操作结束");
                },
                success: function (layero, index) {
                    layui.layer.getChildFrame('body', index);
                    setTimeout(function () {
                        layui.layer.tips('点击此处返回客户列表', '.layui-layer-setwin .layui-layer-close ', {
                            tips: 3
                        });
                    }, 500)
                },

            })
            layui.layer.full(index);
        }



        //监听工具条
        table.on('tool(userTable)', function(obj) {//注：tool是工具条事件名，demo是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data;//获得当前行数据
            if (obj.event === 'edit') {//获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                var location = "useredit.html?userId="+data.userId;
                addNews(location);
            }
        });

    });
</script>
</body>
</html>